﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kristall.Engine;
using Kristall.Engine.Scripts;

namespace Kristall.MyGame.Scripts
{
    public class CheckPointScript : Script
    {
        Level _level;
        AABB _aabb;

        public CheckPointScript()
        {
            this.OnCollision += new EventHandler<CollisionEventArgs>(CheckPointScript_OnCollision);
        }

        void CheckPointScript_OnCollision(object sender, CollisionEventArgs e)
        {
            if (!_level.Player.CheckPoint.Equals(_aabb.Center))
            {
                _level.Player.CheckPoint = _aabb.Center;
                Kristall.SoundManager.PlayNonInstancedSound("CheckPoint");
            }
        }

        public override void Load(Level level, AABB aabb)
        {
            _level = level;
            _aabb = aabb;
        }
    }
}
